package com.example.themyno1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.Toast;
public class MainActivity extends AppCompatActivity {

    private Button btn1;
    private ImageView img_icon;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        //2.绑定控件
        btn1 = findViewById(R.id.btn_login);
        img_icon = findViewById(R.id.img_icon);
        //设置监听事件
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //实现功能代码
                Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
                img_icon.setImageResource(R.drawable.head);
            }
        });
    }
}